<template>
  <div v-show="isshow" id="toast">
    <div>{{message}}</div>
  </div>
</template>

<script>
export default {
  name:"Toast",
  props:{
    // message:{
    //   type:String,
    //   default:''
    // },
    // show:{
    //   type:Boolean,
    //   default:false
    // }
  },
  data(){
    return{
      message:'',
      isshow:false
    }
  },
  methods:{
    show(message = '默认文字',duration = 1500){
      // const box = document.getElementById('toast')
      this.isshow = true
      this.message = message
      setTimeout(()=>{
        // box.className += "hide"
        // setTimeout(()=>{
          this.isshow = false
          // box.className = ''
        // },duration/3)
      // },(duration/3)*2)
      },duration)
    }
  }
}
</script>

<style scoped>
#toast{
    position: fixed;
    border-radius: 30px;
    font-size: 13px;
    top: 90%;
    left: 43.5%;
    transform: translate(-50% ,-50%);
    padding: 8px 30px;
    color: #fff;
    background-color: rgba(0,0,0,.8);
    transition: all .3s linear;
    z-index: 999;
    /* opacity: 1;
    visibility: visible; */
  }
  /* .hide{
    opacity: 0;
    visibility: hidden;
  } */
</style>